package system.service.impl;

import common.model.po.SysUser;
import common.model.response.base.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import system.service.TestService;

/**
 * 描述
 *
 * @author 米泽鹏
 * @since 2023-9-18 上午 11:40
 */
@Service
@Slf4j
public class TestServiceImpl implements TestService {

	@Override
	@Transactional(rollbackFor = Exception.class)
	public Result<?> saveUser() {
		SysUser user = new SysUser();
		user.setNickname("用户1");
		user.setUsername("yonghu1");
		user.setPassword("123456");
		user.setSalt("salt");
		user.setValid(1);
		user.setOperator("yonghu1");
		user.insert();
		saveUser2().throwExceptionIfFailed();
		return Result.success();
	}

	private Result<?> saveUser2() {
		SysUser user = new SysUser();
		user.setNickname("用户2");
		user.setUsername("yonghu2");
		user.setPassword("123456");
		user.setSalt("salt");
		user.setValid(1);
		user.setOperator("yonghu2");
		user.insert();
		int a = 1 / 0;
		return Result.success();
	}

}
